<!DOCTYPE html>
<HTML><head> 
    <meta charset="utf-8"/>
<title>BEFORE POSTING UPDATE |http://www.fullblogdesign.com</title>
<link rel="icon" type="image/gif" href="favicon.ico" />
    <style type="text/css">
body{background-color:#e1e1e1;font:normal 11px Tahoma,Verdana,Arial,Sans-Serif;color:#333;padding:20px}
        textarea{width:60%;min-height:150px;margin:10px;border:none;padding:10px;background:#b0c4de;text-align:left;box-shadow:2px 2px 3px #000}

    </style>
</head>
<body>

<H1>Before Posting Update :</H1>
<textarea id="target-textarea">
isikan apa saja disini 
</textarea>
<br/>
<button onclick="wrapText('&lt;script type=&quot;text/javascript&quot;&gt;', '&lt;/script&gt;', document.getElementById('target-textarea'));">script</button>
<button onclick="wrapText('&lt;style type=&quot;text/css&quot;&gt;', '&lt;/style&gt;', document.getElementById('target-textarea'));">Style</button>
</div>
<button onclick="wrapText('&lt;script src=&quot;http://.js&quot; type=&quot;text/javascript&quot;&gt;', '&lt;/script&gt;', document.getElementById('target-textarea'));">Ex-script</button>
<button onclick="wrapText('&lt;link href=&quot;Url.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;/&gt;', '', document.getElementById('target-textarea'));">EX style</button>
<button onclick="wrapText('&lt;div class=&quot; &quot;&gt;', '&lt;/div&gt;', document.getElementById('target-textarea'));">class</button>
<button onclick="wrapText('&lt;div id=&quot; &quot;&gt;', '&lt;/div&gt;', document.getElementById('target-textarea'));">div id</button>
<button onclick="wrapText('&lt;a href=&quot;/&quot; title=&quot;data-title&quot; target=&quot;_blank&quot;&gt;', '</a>', document.getElementById('target-textarea'));">link</button>
<button onclick="wrapText('<blockquote>', '</blockquote>', document.getElementById('target-textarea'));">blockquote</button>
<button onclick="wrapText('&lt;img src=&quot;Ulr-image &quot; alt=&quot;image&quot; title=&quot;title-image&quot;/&gt;', '', document.getElementById('target-textarea'));">Image</button>
<button onclick="wrapText('<span style=&quot;color:..&quot;>', '</span>', document.getElementById('target-textarea'));">Color</button>
<button onclick="wrapText('<strong>', '</strong>', document.getElementById('target-textarea'));">Bold</button>
<button onclick="wrapText('<em>', '</em>', document.getElementById('target-textarea'));">Italic</button>
<button onclick="wrapText('<ins>', '</ins>', document.getElementById('target-textarea'));">Underline</button>
</div><br/><br/>
<h3>PARSE-HTML:</h3>
<textarea placeholder="Add script/coded here for convert" onchange="do_encode(this)" onkeyup="do_encode(this)" rows="7" cols="75" style="font-family:monospace"></textarea><br/><br/>
<H3>COPY-SCRIPT:</h3>
<textarea readonly="readonly" onclick="this.select()" onfocus="this.select()" id="dst" rows="7" cols="75" style="font-family:monospace"></textarea>

<script>
// Mendukung untuk semua peramban mayor dan IE8+
function wrapText(str1, str2, elem) {
    var value = elem.value,
        before = value.substring(0, elem.selectionStart),
        selected = value.substring(elem.selectionStart, elem.selectionEnd),
        after = value.substring(elem.selectionEnd, value.length),
        pos = before.length + str1.length + selected.length + str2.length;
    elem.value = before + str1 + selected + str2 + after;
    setSelectionRange(elem, before.length, pos);
}

// http://stackoverflow.com/a/499158
function setSelectionRange(input, selectionStart, selectionEnd) {
    if (input.setSelectionRange) {
        input.focus();
        input.setSelectionRange(selectionStart, selectionEnd);
    } else if (input.createTextRange) {
        var range = input.createTextRange();
        range.collapse(true);
        range.moveEnd('character', selectionEnd);
        range.moveStart('character', selectionStart);
        range.select();
    }
}
</script>
<!--script-parse-->
<script>
    function clearTextArea() {
      document.getElementById("code").value = '';
    }

    function $(id) {
      return document.getElementById(id)
    }
    var char2entity = {
      "'": '&#39;',
      '"': '&quot;',
      '<': '&lt;',
      '>': '&gt;',
      '&': '&amp;'
    };

    function encode_entities(str) {
      var rv = '';
      for (var i = 0; i < str.length; i++) {
        var ch = str.charAt(i);
        rv += char2entity[ch] || ch;
      }
      return rv;
    }

    function do_encode(e) {
      $('dst').value = encode_entities(e.value)
    }
	function goBack()
    {
    window.history.back()
    }
    </script>

</body>
</HTML>